﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeAgeDetaiSuspendAdd.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeAgeDetaiSuspendAdd" %>
<%--缓期添加--%>

<div class="pageContent">
	<form method="post" action="FTradeModel/FTradeAgeDetaiSuspendAdd.aspx?ajaxmethod=add&FTradeAgeId=<%=FTradeAgeId %>" class="pageForm required-validate" onsubmit="return validateCallbackFTradeAgeDetaiSuspendAdd(this, dialogAjaxDone)">
		<div class="pageFormContent" layoutH="58">
			 
            <h2>原需付款信息</h2>
              <div class="divider"></div>
              <p>
				<label><%=obj.ShowTitle %>：</label>
				<input  type="text" class="" value="<%=obj.JinE %>" readonly />
			  </p>
			  <p>
				<label>已付金额：</label>
				<input  type="text" class="" value="<%=obj.YiChongJinE %>" readonly />
                <span class="unit">元</span>
			  </p>
              <p>
				<label>未付金额：</label>
				<input  type="text" class="" value="<%=obj.JinE-obj.YiChongJinE %>" readonly />
                <span class="unit">元</span>
			  </p>
              <div class="divider"></div>
              <p>
				<label >原到期日：</label>
				<input  type="text" class="" value="<%= obj.DaoQiRi.ToString("yyyy-MM-dd") %>" readonly />
			  </p>
             <p>
				<label >冲帐状态：</label>
				<input  type="text" class="" value="<%=obj.ChonZhanState %>" readonly />
			  </p>
            <p>
				<label >备注：</label>
				<input  type="text" class="" value="<%= obj.Remark %>" readonly />
			  </p>
            <div class="divider"></div>
             <h2>本次延期付款申请信息<span style=" padding:5px 0px; color:red; font-size:11px;">(本次申请延期的金额不能超过 <%=obj.JinE-obj.YiChongJinE %>)</span></h2>
             
            <div class="divider"></div>
            <table class="list FTradeAgeDetaiSuspendAddTable" width="100%">
                <thead>
                    <tr>
                        <th width="5%" >#</th><th>款项名称</th><th>金额</th><th>新的到期日</th><th>年利率</th><th>短缺成本</th><th >备注</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,1) %>" />1</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.1"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                    <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,2) %>" />2</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.2"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                     <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,3) %>" />3</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.3"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                    <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,4) %>" />4</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.4"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                    <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,5) %>" />5</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.5"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                    <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,6) %>" />6</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.6"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                    <tr>
                       <td><input type="hidden" name="ShowIndex" value="<%=GetShowIndex(obj.ShowIndex,7) %>" />7</td>
                        <td><input  type="text" name="ShowTitle" style="width:120px" class="textInput inputGetFormLimtt" value="<%=obj.ShowTitle %>.7"/></td>
                        <td><input  type="text" name="JinE" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="DaoQiRi" style="width:120px" class=" date onchangeDaoQiRi" value=""/></td>
                        <td><input  type="text" name="YearRate" style="width:120px" class="required inputFloat onchangeDaoQiRi" value="0"/></td>
                        <td><input  type="text" name="TanQeChenBen" style="width:120px" class="required inputFloat" value="0"/></td>
                        <td><input  type="text" name="Remark" style="width:120px" class="inputGetFormLimtt" value=""/></td>
                    </tr>
                </tbody>
            </table>
		</div>
		<div class="formBar">
			<ul>
				<li id="FTradeAgeDetaiSuspendAdd_BtnSave"><div class="buttonActive"><div class="buttonContent"><button type="submit">确定</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div>
	</form>
	
</div>
<script>
    //新增时需要处理 金额是否与合同金额一致
    function validateCallbackFTradeAgeDetaiSuspendAdd(form, callback) {
        var $form = $(form);
        var $weiFuKuan = <%=obj.JinE-obj.YiChongJinE %>;
      
        var $inputPageJinE = 0;
        $form.find("table.FTradeAgeDetaiSuspendAddTable").find(":text[name='JinE']").each(function () {
            if($(this).val()=="")
                $(this).val("0");
            $inputPageJinE = $inputPageJinE + parseFloat($(this).val());
        });
       // alert(parseFloat($inputPageJinE).toFixed(2))

        //alert(parseFloat($weiFuKuan).toFixed(2))
        if ( parseFloat($inputPageJinE) > parseFloat($weiFuKuan)) {
            alertMsg.warn("本次延期付款总金额超出未付金额,请检查更改后再提交.");
            return false;
        }

        $("#FTradeAgeDetaiSuspendAdd_BtnSave").find("button").attr("disabled", "disabled").html("添加中......");
        setTimeout(function () { $("#FTradeAgeDetaiSuspendAdd_BtnSave").find("button").removeAttr("disabled").html(" 确  定 "); }, 3000);

        return validateCallback(form, callback);
    }

    $(document).ready(function(){
        $(".onchangeDaoQiRi").blur(function(){
            
            var $YearRate= parseFloat($(this).closest("tr").find("input[name='YearRate']").val()).toFixed(6);  
           
            var $day=DateDiff("<%= obj.DaoQiRi.ToString("yyyy-MM-dd") %>",$(this).closest("tr").find("input[name='DaoQiRi']").val());
          
            var $JinE= parseFloat($(this).closest("tr").find("input[name='JinE']").val()).toFixed(6);          
           
            var $TanQeChenBen=0;
            $TanQeChenBen=$JinE*($YearRate/360)*$day;           
            $(this).closest("tr").find("input[name='TanQeChenBen']").val($TanQeChenBen.toFixed(2));

        })
    })

    function  DateDiff(sDate1,  sDate2){    //sDate1和sDate2是2006-12-18格式    
        var  aDate,  oDate1,  oDate2,  iDays    
        aDate  =  sDate1.split("-")    
        oDate1  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0])    //转换为12-18-2006格式    
        aDate  =  sDate2.split("-")    
        oDate2  =  new  Date(aDate[1]  +  '-'  +  aDate[2]  +  '-'  +  aDate[0])    
        iDays  =  parseInt(Math.abs(oDate1  -  oDate2)  /  1000  /  60  /  60  /24)    //把相差的毫秒数转换为天数   
        return  iDays
    }
</script>
